<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>统计</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../../css/reset.css" />
		<link rel="stylesheet" href="../../../css/mui.min.css" />
		<link rel="stylesheet" href="../../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../../css/mui.poppicker.css" />
		<link rel="stylesheet" href="../../../css/iconfont.css" />
		<link rel="stylesheet" href="../../../css/cmms.css" />
		<link rel="stylesheet" href="../../../css/sale/index.css" />
		<link rel="stylesheet" href="../../../css/doctor/index.css" />
		<link rel="stylesheet" href="../../../css/doctor/statistics.css" />
	</head>
	<body>
		<div class="mui-content" id="index" v-cloak>
			<div id="tabbar" class="mui-control-content mui-active">
				<div class="addr overflow">
					<i class="iconfont icon-dizhi left"></i>
					<span class="left" id="showUserPicker">{{doctorName}}</span>
					<i class="iconfont icon-jiantou"></i>
				</div>
				<div class="showPanel">
			    	<div class="overflow panelContainer">
			    		<div class="center">
			    			<div class="center num">{{dataList.amounts}}</div>
			    			<div class="center todayCheck">本月累计检验金额(元)</div>
			    		</div>
			    	</div>
			    </div>
			    <div class="overflow panelContainer1">
			    		<div class="left">
			    			<div class="center num">{{dataList.outOrderDays}}</div>
			    			<div class="center todayCheck">出单天数</div>
			    		</div>
			    		<div class="left">
			    			<div class="center num">{{dataList.commissionAmounts}}</div>
			    			<div class="center todayCheck">累计收入(元)</div>
			    		</div>
			    		<div class="left">
			    			<div class="center num">{{dataList.patientTotals}}</div>
			    			<div class="center todayCheck">累计检验人次</div>
			    		</div>
			    </div>
			</div>
			<div class="statictis-detail">
				<section class="panel padding0_16 statictis-panel" v-for="t in dataList.list">
					<div class="border-bottom-1px overflow">
						<i class="iconfont icon-qianbao1"></i>
						<span>{{t.payTime |replaceT}}</span>
						<span class="right">已支付</span>
					</div>
					<div class="border-bottom-1px overflow center statictis-data">
						<div class="left">
							<div class="font12_9">收入(元)</div>
							<div><span class="orange">{{t.commissionAmount | moneyBig}}</span><span class="orange font10">{{t.commissionAmount|moneySmall}}</span></div>
						</div>
						<div class="left">
							<div class="font12_9">检验人次</div>
							<div class="font12_3">{{t.patientTotal}}</div>
						</div>
						<div class="left">
							<div class="font12_9">检验费</div>
							<div class="font12_3">{{t.amount}}</div>
						</div>
						<div class="left">
							<div class="font12_9">分成</div>
							<div class="font12_3">{{t.commissionAmount}}</div>
						</div>
					</div>
					<div class="overflow">
						<span class="font12_9">应付：</span>
						<span class="font12_3">{{t.settleAmount}}</span>
						<span class="primary-money">已付：{{t.actualAmount}}</span>
					</div>
				</section>
			</div>
		</div>
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/mui.picker.js"></script>
		<script src="../../../js/mui.poppicker.js"></script>
		<script src="../../../js/vue.js"></script>
		<script src="../../../js/cmms.js?time=333"></script>
		<script>
			new Vue({
				el:"#index",
				data:{
//					today:'',
					doctorList:[],
					doctorName:"1111",
					userId:0,
					hospitalId:'',
					dataList:''
				},
				mounted(){
//					this.today=new Date();
					this.userId = localStorage.getItem("userID");
					this.init();
				},
				methods:{
					muiInit(){
						let _this = this;
						(function($) {
							$.init();
							$.ready(function() {
								var userPicker = new $.PopPicker();
								userPicker.setData(_this.doctorList);
								var showUserPickerButton = document.getElementById('showUserPicker');
								showUserPickerButton.addEventListener('tap', function(event) {
									userPicker.show(function(items) {
										_this.doctorName = items[0].text;
										_this.userId = items[0].value;
										console.log(_this.userId);
										console.log(_this.userId === '-1');
										//1代表医院  0代表用户(医生)
										if(_this.userId === '-1'){
											_this.getStatistics(_this.hospitalId,1);
										}else{
											_this.getStatistics(_this.userId,0);
										}
										
										//返回 false 可以阻止选择框的关闭
										//return false;
									});
								}, false);
							});
						})(mui);
					},
					//获取统计信息
					getStatistics:function(id,type){
						let _this = this;
						let params = "";
						console.log(type);
						if(type === 0){
							params = {doctorId:id}
						}else{
							params = {hospitalId:id}
						}
						AT.muiAjaxDoctor("/clinic-doctor/statistics/get","post",
							params,function(res){
//								console.log(res);
							_this.dataList = res;
						})
					},
					toDetail(url){
						location.href = url;
					},
					
					tocheckDetail:function(){
						location.href = this.checkDetail;
					},
					init:function(){
						let _this = this;
//						mui('.mui-table-view').on('tap','li',function(){
//							let tap = this.getAttribute('data-tap');
//						})
						AT.muiAjaxDoctor("/clinic-doctor/order/getHospitalUser","post",{},function(res){
							//整合后台数据
							if(res.hospitalName){
								res.list.push({
								doctorId:'-1',doctorName:res.hospitalName});
							}
							if(_this.userId === res.hospitalId){
								_this.getStatistics(res.hospitalId,1);
							}else{
								_this.getStatistics(_this.userId,0);
							}
							_this.hospitalId = res.hospitalId;
							let arr = res.list;
							let doctorList = [];
							//整理成mui需要的数据格式
							for(let i in arr){
								if(arr[i].doctorId == _this.userId){
									_this.doctorName = arr[i].doctorName
								}
								doctorList.push({value:arr[i].doctorId,text:arr[i].doctorName})
							}
							_this.doctorList = doctorList;
							_this.muiInit();
							
						})
					}
				},
				filters:{
					moneyBig(m){
						return (m+'').split(".")[0]+'.';
					},
					moneySmall(m){
						return (m+'').split(".")[1];
					}
				}
			})
		</script>
	</body>
</html>
